function [ a ] = alpha( s, g )

    a = zeros(s,2);
       
    for i = 1:s
        if(i == 1)
            a(i,1) = 0;
            a(i,2) = 1;
        else
            a(i,1) = a(i-1,1)*M(1,1,i-1,g) + a(i-1,2)*M(2,1,i-1,g);
            a(i,2) = a(i-1,1)*M(1,2,i-1,g) + a(i-1,2)*M(2,2,i-1,g);
        end
    end

end

function [ m ] = M( y_, y, i, g )
    m = exp(g(y_,y,i));
end